home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / javax / swing / JToolBar.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  5.8 KB  |  262 lines

  1. package javax.swing;
  2.  
  3. import java.awt.Component;
  4. import java.awt.Dimension;
  5. import java.awt.Graphics;
  6. import java.awt.Insets;
  7. import java.awt.LayoutManager;
  8. import java.beans.PropertyChangeListener;
  9. import java.io.IOException;
  10. import java.io.ObjectOutputStream;
  11. import javax.accessibility.Accessible;
  12. import javax.accessibility.AccessibleContext;
  13. import javax.swing.plaf.ToolBarUI;
  14.  
  15. public class JToolBar extends JComponent implements SwingConstants, Accessible {
  16.    private static final String uiClassID = "ToolBarUI";
  17.    private boolean paintBorder;
  18.    private Insets margin;
  19.    private boolean floatable;
  20.    private int orientation;
  21.  
  22.    public JToolBar() {
  23.       this(0);
  24.    }
  25.  
  26.    public JToolBar(int var1) {
  27.       this((String)null, var1);
  28.    }
  29.  
  30.    public JToolBar(String var1) {
  31.       this(var1, 0);
  32.    }
  33.  
  34.    public JToolBar(String var1, int var2) {
  35.       this.paintBorder = true;
  36.       this.margin = null;
  37.       this.floatable = true;
  38.       this.orientation = 0;
  39.       this.setName(var1);
  40.       this.checkOrientation(var2);
  41.       this.orientation = var2;
  42.       DefaultToolBarLayout var3 = new DefaultToolBarLayout(this, var2);
  43.       this.setLayout(var3);
  44.       this.addPropertyChangeListener(var3);
  45.       this.updateUI();
  46.    }
  47.  
  48.    public ToolBarUI getUI() {
  49.       return (ToolBarUI)this.ui;
  50.    }
  51.  
  52.    public void setUI(ToolBarUI var1) {
  53.       super.setUI(var1);
  54.    }
  55.  
  56.    public void updateUI() {
  57.       this.setUI((ToolBarUI)UIManager.getUI(this));
  58.       if (this.getLayout() == null) {
  59.          this.setLayout(new DefaultToolBarLayout(this, this.getOrientation()));
  60.       }
  61.  
  62.       this.invalidate();
  63.    }
  64.  
  65.    public String getUIClassID() {
  66.       return "ToolBarUI";
  67.    }
  68.  
  69.    public int getComponentIndex(Component var1) {
  70.       int var2 = this.getComponentCount();
  71.       Component[] var3 = this.getComponents();
  72.  
  73.       for(int var4 = 0; var4 < var2; ++var4) {
  74.          Component var5 = var3[var4];
  75.          if (var5 == var1) {
  76.             return var4;
  77.          }
  78.       }
  79.  
  80.       return -1;
  81.    }
  82.  
  83.    public Component getComponentAtIndex(int var1) {
  84.       int var2 = this.getComponentCount();
  85.       if (var1 >= 0 && var1 < var2) {
  86.          Component[] var3 = this.getComponents();
  87.          return var3[var1];
  88.       } else {
  89.          return null;
  90.       }
  91.    }
  92.  
  93.    public void setMargin(Insets var1) {
  94.       Insets var2 = this.margin;
  95.       this.margin = var1;
  96.       this.firePropertyChange("margin", var2, var1);
  97.       this.revalidate();
  98.       this.repaint();
  99.    }
  100.  
  101.    public Insets getMargin() {
  102.       return this.margin == null ? new Insets(0, 0, 0, 0) : this.margin;
  103.    }
  104.  
  105.    public boolean isBorderPainted() {
  106.       return this.paintBorder;
  107.    }
  108.  
  109.    public void setBorderPainted(boolean var1) {
  110.       if (this.paintBorder != var1) {
  111.          boolean var2 = this.paintBorder;
  112.          this.paintBorder = var1;
  113.          this.firePropertyChange("borderPainted", var2, var1);
  114.          this.revalidate();
  115.          this.repaint();
  116.       }
  117.  
  118.    }
  119.  
  120.    protected void paintBorder(Graphics var1) {
  121.       if (this.isBorderPainted()) {
  122.          super.paintBorder(var1);
  123.       }
  124.  
  125.    }
  126.  
  127.    public boolean isFloatable() {
  128.       return this.floatable;
  129.    }
  130.  
  131.    public void setFloatable(boolean var1) {
  132.       if (this.floatable != var1) {
  133.          boolean var2 = this.floatable;
  134.          this.floatable = var1;
  135.          this.firePropertyChange("floatable", var2, var1);
  136.          this.revalidate();
  137.          this.repaint();
  138.       }
  139.  
  140.    }
  141.  
  142.    public int getOrientation() {
  143.       return this.orientation;
  144.    }
  145.  
  146.    public void setOrientation(int var1) {
  147.       this.checkOrientation(var1);
  148.       if (this.orientation != var1) {
  149.          int var2 = this.orientation;
  150.          this.orientation = var1;
  151.          this.firePropertyChange("orientation", var2, var1);
  152.          this.revalidate();
  153.          this.repaint();
  154.       }
  155.  
  156.    }
  157.  
  158.    public void setRollover(boolean var1) {
  159.       this.putClientProperty("JToolBar.isRollover", var1 ? Boolean.TRUE : Boolean.FALSE);
  160.    }
  161.  
  162.    public boolean isRollover() {
  163.       Boolean var1 = (Boolean)this.getClientProperty("JToolBar.isRollover");
  164.       return var1 != null ? var1 : false;
  165.    }
  166.  
  167.    private void checkOrientation(int var1) {
  168.       switch (var1) {
  169.          case 0:
  170.          case 1:
  171.             return;
  172.          default:
  173.             throw new IllegalArgumentException("orientation must be one of: VERTICAL, HORIZONTAL");
  174.       }
  175.    }
  176.  
  177.    public void addSeparator() {
  178.       this.addSeparator((Dimension)null);
  179.    }
  180.  
  181.    public void addSeparator(Dimension var1) {
  182.       Separator var2 = new Separator(var1);
  183.       this.add(var2);
  184.    }
  185.  
  186.    public JButton add(Action var1) {
  187.       JButton var2 = this.createActionComponent(var1);
  188.       var2.setAction(var1);
  189.       this.add(var2);
  190.       return var2;
  191.    }
  192.  
  193.    protected JButton createActionComponent(Action var1) {
  194.       1 var2 = new 1(this);
  195.       if (var1 != null && (var1.getValue("SmallIcon") != null || var1.getValue("SwingLargeIconKey") != null)) {
  196.          ((JButton)var2).setHideActionText(true);
  197.       }
  198.  
  199.       ((JButton)var2).setHorizontalTextPosition(0);
  200.       ((JButton)var2).setVerticalTextPosition(3);
  201.       return var2;
  202.    }
  203.  
  204.    protected PropertyChangeListener createActionChangeListener(JButton var1) {
  205.       return null;
  206.    }
  207.  
  208.    protected void addImpl(Component var1, Object var2, int var3) {
  209.       if (var1 instanceof Separator) {
  210.          if (this.getOrientation() == 1) {
  211.             ((Separator)var1).setOrientation(0);
  212.          } else {
  213.             ((Separator)var1).setOrientation(1);
  214.          }
  215.       }
  216.  
  217.       super.addImpl(var1, var2, var3);
  218.       if (var1 instanceof JButton) {
  219.          ((JButton)var1).setDefaultCapable(false);
  220.       }
  221.  
  222.    }
  223.  
  224.    private void writeObject(ObjectOutputStream var1) throws IOException {
  225.       var1.defaultWriteObject();
  226.       if (this.getUIClassID().equals("ToolBarUI")) {
  227.          byte var2 = JComponent.getWriteObjCounter(this);
  228.          --var2;
  229.          JComponent.setWriteObjCounter(this, var2);
  230.          if (var2 == 0 && this.ui != null) {
  231.             this.ui.installUI(this);
  232.          }
  233.       }
  234.  
  235.    }
  236.  
  237.    protected String paramString() {
  238.       String var1 = this.paintBorder ? "true" : "false";
  239.       String var2 = this.margin != null ? this.margin.toString() : "";
  240.       String var3 = this.floatable ? "true" : "false";
  241.       String var4 = this.orientation == 0 ? "HORIZONTAL" : "VERTICAL";
  242.       return super.paramString() + ",floatable=" + var3 + ",margin=" + var2 + ",orientation=" + var4 + ",paintBorder=" + var1;
  243.    }
  244.  
  245.    public void setLayout(LayoutManager var1) {
  246.       LayoutManager var2 = this.getLayout();
  247.       if (var2 instanceof PropertyChangeListener) {
  248.          this.removePropertyChangeListener((PropertyChangeListener)var2);
  249.       }
  250.  
  251.       super.setLayout(var1);
  252.    }
  253.  
  254.    public AccessibleContext getAccessibleContext() {
  255.       if (this.accessibleContext == null) {
  256.          this.accessibleContext = new AccessibleJToolBar(this);
  257.       }
  258.  
  259.       return this.accessibleContext;
  260.    }
  261. }
  262.